<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .banner {
            height: 652px;
            background-image: url('./images/jd/s_01_01.gif');
        }

        .sc {
            height: 1027px;
            background-image: url('./images/jd/s_01_02.gif');
        }

        .relex {
            height: 6046px;
            background-image: url('./images/jd/s_01_03.jpg');
        }

        .top-bar {
            height: 52px;
            width: 100%;
            background-image: url('./images/jd/top-bar.png');
            position: fixed;
            top: -52px;
            left: 0;
            z-index: 9;
        }

        .mid {
            height: 60px;
            width: 100%;
            background-image: url('./images/jd/mid.png');
            position: fixed;
            top: -60px;
            left: 0;
        }

        .top-bar,
        .mid {
            transition: top .5s;
        }
    </style>
</head>

<body>
    <div class="big">
        <div class="banner"></div>
        <div class="sc"></div>
        <div class="relex"></div>
    </div>
    <div class="top-bar"></div>
    <div class="mid"></div>
    <script>
        var banner = document.querySelector('.banner')
        var sc = document.querySelector('.sc')
        var bar = document.querySelector('.top-bar')
        var mid = document.querySelector('.mid')

        let t1 = banner.offsetHeight;
        let t2 = sc.offsetHeight;

        window.onscroll = function () {
            let st = document.documentElement.scrollTop;
            if (st < t1) {
                bar.style.top = ''
                mid.style.top = ''
            } else if (st < t2) {
                bar.style.top = 0;
                mid.style.top = ''
            } else {
                bar.style.top = 0;
                mid.style.top = 52 + 'px'
            }
        }
    </script>
</body>

</html>